﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EasySL.UI.Controls
{
    public partial class Menu : UserControl
    {
        public MouseButtonEventHandler OnClick;
        
        public Menu()
        {
            InitializeComponent();
            this.BindMenuEvent();
        }

        void BindMenuEvent()
        {
            foreach (TreeViewItem rootItem in this.menu.Items)
            {
                foreach (TreeViewItem item in rootItem.Items)
                {
                    if (item.Tag != null)
                    {
                        item.MouseLeftButtonUp += new MouseButtonEventHandler(item_MouseLeftButtonUp);
                    }
                }
            }
        }

        void item_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (OnClick != null)
                OnClick(sender, e);
             
        }
    }
}
